/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import TableView.SectionTable;
import data.Sections;
import java.util.List;
import java.util.Set;
import util.BaseDAO;

/**
 *
 * @author Hùng
 */
public class SectionDAO extends BaseDAO {

    public List<Sections> getAllSections(String deptname) {
        String hql = " from Sections s where s.departments.deptname = '" + deptname+"'";
        List<Sections> lSec = executeHQLQuery(hql);
        return lSec;
    }

    public Sections getSectionbyNameSec(String tmpNameSec) {
        String hql = "from Sections a where a.sectname = '" + tmpNameSec + "'";
        List<Sections> lSec = executeHQLQuery(hql);
        if(lSec.size() == 0){
            return null;
        }
        return lSec.get(0);

    }
    public SectionTable showTableSection(){
		SectionTable model = new SectionTable(getAllSection());
		return model;
	}
	public List<Sections> getAllSection(){
		String sql = "from Sections";
		return executeHQLQuery(sql);
	}
}
